package com.ruoyi.service.impl;

import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.domain.T06;
import com.ruoyi.service.IPcService;
import com.ruoyi.service.IT06Service;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class PcServiceImpl implements IPcService {
    @Autowired
    private ISysUserService sysUserService;
    @Autowired
    private ISysDeptService sysDeptService;
    @Autowired
    private IT06Service t06Service;
    @Override
    public List<T06> getUserList(Long userId) {
        SysUser user = sysUserService .selectUserById(userId);
        Long deptId = user.getDeptId();
        SysDept sysDept = sysDeptService.selectDeptById(deptId);
//        SysDept parentDept = sysDeptService.selectDeptById(sysDept.getParentId());
        List<Long> list = sysDeptService.selectDeptChildren(sysDept.getDeptId());
        List<T06> nlist = new ArrayList<>();
        for (Long F0501 : list){
            nlist .add(t06Service.selectByDeptId(F0501));
        }
        return nlist;
    }
}
